package com.github.wxpay.sdk.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by tyf on 2018/11/19
 */
public class CollectionUtils {

    public static Map mapRemoveWithNullByRecursion(Map map) {
        Set<Map.Entry<String, Object>> set = map.entrySet();
        Iterator<Map.Entry<String, Object>> it = set.iterator();
        Map map2 = new HashMap();
        while (it.hasNext()) {
            Map.Entry<String, Object> en = it.next();
            if (!(en.getValue() instanceof Map)) {
                if (null == en.getValue() || "".equals(en.getValue())) {
                    it.remove();
                }
            } else {
                map2 = (Map) en.getValue();
                mapRemoveWithNullByRecursion(map2);
            }
        }
        return map;
    }


}
